class Machine < ActiveRecord::Base

   #Validacion para que los campos requeridos no sean nulos
  validates_presence_of :latitude
  validates_presence_of :longitude
  validates_presence_of :status
  validates_presence_of :state
  validates_presence_of :zone
  validates_presence_of :model
  validates_presence_of :brand
  validates_presence_of :version
  validates_presence_of :os
  validates_presence_of :disc
  validates_presence_of :ram
  validates_presence_of :processor
  validates_presence_of :cant_ap

  #Validacion para que exista un limite para la entrada de datos
   validates_length_of :model, :maximum=>15, :message=>"Max lenght it's %d characters"
   validates_length_of :brand, :maximum=>15, :message=>"Max lenght it's %d characters"
   validates_length_of :version, :maximum=>15, :message=>"Max lenght it's %d characters"
   validates_length_of :os, :maximum=>15, :message=>"Max lenght it's %d characters"


   #Valida que no se puedan incluir letras en el campo
    validates_numericality_of :disc,:greater_than => 0
    validates_numericality_of :ram,:greater_than => 0
    validates_numericality_of :cant_ap,:greater_than => 0


   #Con esta funcion se cambia los nombres de los atributos que salen por defauyt
  #en el cuadro de errores que trae ruby
  HUMAN_ATTRIBUTES = {
   :latitude => "Latitude",
   :longitude => "Longitude",
   :status => "Status(Enable/Disable)",
   :state => "State Location",
   :zone => "Zone Location",
   :model => "Model Machine",
   :brand => "Brand Machine",
   :version => "Version Machine",
   :os => "Operative System",
   :disc => "Disk Capacity",
   :ram => "Memory Ram",
   :processor => "Type Processor",
   :cant_ap => "Amount to bet"

 }

  def self.human_attribute_name(attr)
    HUMAN_ATTRIBUTES[attr.to_sym] || super
  end



  #Relaciones con respecto a la cardinalidad de las tablas con respecto a la
  #de datos.
  belongs_to :administrator
  has_many :gambles

end
